package com.angel.arquitectura.test.factory;

import com.angel.arquitectura.model.configuration.ConfigurationParameter;
import org.apache.commons.lang.RandomStringUtils;

import java.util.Date;

/**
 *
 * @author William
 */
public class PTDomainObjectFactory {

    private PTDomainObjectFactory(){
        super();
    }

    public static ConfigurationParameter buildConfigurationParameter(){
        ConfigurationParameter configurationParameter = new ConfigurationParameter();
        configurationParameter.setName(RandomStringUtils.randomAlphabetic(10));
        configurationParameter.setDescription(RandomStringUtils.randomAlphabetic(10));
        configurationParameter.setStringValue(RandomStringUtils.randomAlphabetic(5));
        configurationParameter.setBooleanValue(randomBoolean());
        configurationParameter.setCharacterValue(randomCharacter());
        configurationParameter.setLongValue(randomLong(4));
        configurationParameter.setDateValue(new Date());
        return configurationParameter;
    }

    private static Character randomCharacter(){ 
        return RandomStringUtils.randomAlphabetic(1).charAt(0);
    }

    private static Long randomLong(Integer digits){
        return Long.valueOf(randomInteger(digits).toString());
    }

    private static Integer randomInteger(Integer digits){ 
        return Integer.valueOf(RandomStringUtils.randomNumeric(digits));
    }

    private static Boolean randomBoolean(){
        Integer number = Integer.valueOf(RandomStringUtils.randomNumeric(2));
        return number > 50;
    }
}